package com.twb.core.propertyEditor;

import com.twb.core.util.MoneyUtil;
import java.beans.PropertyEditorSupport;
import java.math.BigDecimal;
import org.apache.commons.lang3.StringUtils;

/**
 * @author DHL
 * @ClassName: MoneyEditor
 * @Description: 金额属性编辑器
 * @date 2022/12/12、8:53
 */
public class MoneyEditor extends PropertyEditorSupport {

    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        if (StringUtils.isBlank(text)) {
            text = "0";
        }
        setValue(MoneyUtil.Y2F(new BigDecimal(text)));
    }

    @Override
    public String getAsText() {
        return getValue().toString();
    }
}
